package com.ebs.md.fxmonitor.performance;

import java.util.List;
import java.util.Map;

import com.ebs.commons.comp.IParsedPayload;

/**
 * <p>Title: NetLink</p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author ygrinberg
 * @version 1.0
 */
public class DumpFields implements LogFormatter
{
    List<Map<String, String>> m_keyFields;


    public DumpFields() {}


    public void setKeyFields(List<Map<String,String>> theFields)
    {
        m_keyFields = theFields;
    }


    public void format(IParsedPayload thePayload,
                                             StringBuilder theContents)
    {
        if((m_keyFields == null) || (m_keyFields.size() <= 0))
        {
            return;
        }
        for(Map<String,String> nextPair : m_keyFields)
        {
            for (String nextKey : nextPair.keySet()) {
                String nextLabel = nextPair.get(nextKey);
                if ((nextLabel != null) && (nextLabel.length() > 0))
                {
                    theContents.append(nextLabel);
                }
                Object nextObj = thePayload.getParsedMessage().get(nextKey);
                if ((nextObj != null) && (nextObj.toString().length() > 0))
                {
                    theContents.append(nextObj.toString());
                }
            }
        }
}




}
